package com.appspot.bibtable.util;

public final class StringUtility
{
	private StringUtility()
	{
		// Cannot be instanciated.
	}
	
	public static String camelcaseToPhrase(String camel)
	{
		if (camel == null)
		{
			return null;
		}
		
		final int length = camel.length();
		for (int index = length - 1; index >= 0; index--)
		{
			char c = camel.charAt(index);
			if (Character.isUpperCase(c))
			{
				if (index == 0)
				{
					camel = Character.toLowerCase(c) + camel.substring(1);
				}
				else
				{
					camel = camel.substring(0, index - 1) + " " + Character.toLowerCase(c) + camel.substring(index + 1);
				}
			}
		}
		
		return camel;
	}
	
	public static boolean isNullOrEmpty(String value)
	{
		return value == null || value.length() == 0;
	}
}
